///*
// * Copyright (c) 2006-2021, RT-Thread Development Team
// *
// * SPDX-License-Identifier: Apache-2.0
// *
// * Change Logs:
// * Date           Author       Notes
// * 2025-06-23     Administrator       the first version
// */
//#include <rtthread.h>
//#include <rtdevice.h>
//
//#define ENCODER_DEVICE_COUNT 4
//
//static const char* encoder_names[ENCODER_DEVICE_COUNT] = {
//    "pulse1",
//    "pulse2",
//    "pulse3",
//    "pulse4"
//};
//
//static rt_device_t pulse_encoder_dev[ENCODER_DEVICE_COUNT] = {RT_NULL};
//
//int encoder_demo_init(void)
//{
//    rt_err_t ret;
//    rt_uint32_t i;
//
//    // 查找设备、打开设备、使能编码器
//    for (i = 0; i < ENCODER_DEVICE_COUNT; i++)
//    {
//        pulse_encoder_dev[i] = rt_device_find(encoder_names[i]);
//        if (pulse_encoder_dev[i] == RT_NULL)
//        {
//            rt_kprintf("Error: Can't find %s device!\n", encoder_names[i]);
//            return -RT_ERROR;
//        }
//
//        ret = rt_device_open(pulse_encoder_dev[i], RT_DEVICE_OFLAG_RDONLY);
//        if (ret != RT_EOK)
//        {
//            rt_kprintf("Error: Open %s failed!\n", encoder_names[i]);
//            return -RT_ERROR;
//        }
//
//        ret = rt_device_control(pulse_encoder_dev[i], PULSE_ENCODER_CMD_ENABLE, RT_NULL);
//        if (ret != RT_EOK)
//        {
//            rt_kprintf("Error: Enable %s failed!\n", encoder_names[i]);
//            return -RT_ERROR;
//        }
//    }
//    rt_int32_t count;
//
////     读取并打印编码器计数值
//        for (int index = 0; index <= 10000; index ++)
//        {
//            rt_thread_mdelay(500);
//            /* 读取脉冲编码器计数值 */
//            rt_device_read(pulse_encoder_dev[0], 0, &count, 1);
//            /* 清空脉冲编码器计数值 */
//            rt_device_control(pulse_encoder_dev[0], PULSE_ENCODER_CMD_CLEAR_COUNT, RT_NULL);
//            rt_kprintf("get count %d\n",count);
//        }
//
//    return RT_EOK;
//}
//
//MSH_CMD_EXPORT(encoder_demo_init, encoder_demo_init);
